package com.edu.mapper;

import com.edu.bean.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author:LYS
 * @Date: 2024/9/20 18:10
 * @Description:
 */
public interface BookMapper {
    @Select("select * from book where bookId = #{bookId}")
    Book selectBookById(int bookId);

    @Select("select * from book")
    List<Book> selectAllBooks();

    @Delete("delete from book WHERE bookId = #{bookId}")
    int deleteBook(int bookId);

    @Insert("INSERT INTO book (bookName,bookWriter,bookType) VALUES (#{bookName},#{bookWriter},#{bookType})")
    int insertUser(Book book);

    @Update(" UPDATE book SET bookName=#{bookName},bookWriter=#{bookWriter},bookType=#{bookType} WHERE bookId=#{bookId}")
    int updateUser(Book book);
}
